<template>
  <div id="demo-child">
    <router-view/>
  </div>
</template>

<script>
import * as echarts from 'echarts';
import { domTitle, setDocumentTitle } from '@/utils/domUtil';
import zh_CN from 'ant-design-vue/lib/locale-provider/zh_CN';
import moment from 'moment';
import 'moment/locale/zh-cn';
moment.locale('zh-cn');
import { onlineDuration } from '@/api/common';
import storage from 'store';

export default {
  data() {
    return {
      zh_CN,
      theme: storage.get('theme') || 'light', //默认主题
    };
  },
  computed: {
    locale() {
      // 只是为了切换语言时，更新标题
      const { title } = this.$route.meta;
      title && setDocumentTitle(`${ title } - ${ domTitle }`);
    },
  },
  mounted() {
    setInterval(() => {
      onlineDuration({}).then((res) => {});
    }, 1000 * 60 * 60);

    const echartsTheme = require(`@/styles/echartsThemes/${ this.theme }.json`);
    echarts.registerTheme('theme', echartsTheme);

    import (`@/styles/themes/${ this.theme }.less`);
  },
};
</script>

<style>
@import "~@/styles/themes/index.less";
</style>
